#银行账户管理系统

#定义账户信息
BankAccount=[
			{'id':'01','password':'001','name':'zhangsan','balance':100},
			{'id':'02','password':'002','name':'lisi','balance':200},
			{'id':'03','password':'003','name':'wangwu','balance':300}
			]

#定义输出模块
def PrintAccount(account):
	print("|{0:<5}|{1:<10}|{2:<10}|".format("id","name","balance"))
	print("|{0:<5}|{1:<10}|{2:<10}|".format(account['id'],account['name'],account['balance']))

while True:
	#登录系统
	AccountEnabled=dict()
	AccountId=input("请输入账号：\n")
	for BA in BankAccount:
		if AccountId==BA['id']:
			AccountPassword=input("请输入密码：\n")
			if AccountPassword==BA['password']:
				AccountEnabled=BA
				break

	#账号存在进入系统
	if AccountEnabled:
		while AccountEnabled:
			#初始界面
			print("\n"*2)
			print("="*12,"银行账户管理系统","="*12)
			print("{0:1}{1:15}{2:15}".format(" ","1.查询","2.存款"))
			print("{0:1}{1:15}{2:15}".format(" ","3.取款","4.退出"))
			print("="*40)
			#根据键盘值，判断并执行对应操作。
			print("\n")
			key=input("请输入对应的选择：")
			print("\n")
			if key=="1":#查询
				print("="*12,"查询","="*12)
				PrintAccount(AccountEnabled)
				input("请按回车键继续：")		
			elif key=="2":#存款
				print("="*12,"存款","="*12)
				AccountEnabled['balance']+=int(input("请输入存款金额："))
				PrintAccount(AccountEnabled)
				input("请按回车键继续：")
			elif key=="3":#取款
				print("="*12,"取款","="*12)
				AccountEnabled['balance']-=int(input("请输入取款金额："))
				PrintAccount(AccountEnabled)
				input("请按回车键继续：")
			elif key=="4":#退出
				print("="*12,"退出","="*12)
				break
			else:
				print("="*12,"无效输入！","="*12)
	#账号不存在
	else:
		print("没有此账户！")
		print("\n")